<template>
	<view class="container">
		<map :latitude="lat" :longitude="lon" class="map-container" :show-location="true">
			<marker :latitude="lat" :longitude="lon" :title="address" />
		</map>

		<view class="bottom-card">
			<view class="info">
				<text class="title">{{ address }}</text>
				<text class="subtitle">{{ location }}</text>
			</view>
			<button class="action-btn">导航前往</button>
		</view>
	</view>
</template>

<script setup>
	import {
		getCurrentInstance,
		onMounted,
		ref
	} from 'vue';
	import {
		onLoad
	} from '@dcloudio/uni-app';

	const address = ref('');
	const location = ref('');
	const lat = ref(0);
	const lon = ref(0);

	onLoad((options) => {
		console.log(options)
		address.value = decodeURIComponent(options.address || '');
		location.value = decodeURIComponent(options.location || '');
		lat.value = parseFloat(options.lat) || 0;
		lon.value = parseFloat(options.lon) || 0;
	})

	// onMounted((res) => {
	// 	console.log(res)
	// 	const instance = getCurrentInstance().proxy
	// 	console.log(instance)
	// // 	console.log(options)
	// // 	address.value = decodeURIComponent(options.address || '');
	// // 	location.value = decodeURIComponent(options.location || '');
	// // 	lat.value = parseFloat(options.lat) || 0;
	// // 	lon.value = parseFloat(options.lon) || 0;
	// });
</script>

<style>
	.container {
		position: relative;
		height: 100vh;
	}

	.map-container {
		width: 100%;
		height: 100%;
	}

	.bottom-card {
		position: fixed;
		bottom: 20px;
		left: 20px;
		right: 20px;
		background: white;
		border-radius: 12px;
		padding: 20px;
		box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.info {
		flex: 1;
		margin-right: 15px;
	}

	.title {
		font-size: 16px;
		font-weight: bold;
		display: block;
		margin-bottom: 8px;
	}

	.subtitle {
		font-size: 14px;
		color: #666;
		display: block;
	}

	.action-btn {
		background: #007AFF;
		color: white;
		padding: 8px 20px;
		border-radius: 6px;
		font-size: 14px;
	}
</style>